package com.bjxst.service.impl;

import com.bjxst.dao.UserloginDao;
import com.bjxst.dao.impl.UserLoginDaoImpl;
import com.bjxst.exception.UserNotFoundException;
import com.bjxst.pojo.Users;
import com.bjxst.service.UserLoginService;
//实现业务层的接口
public class UserLoginServiceImpl implements UserLoginService {
    @Override
    public Users userLogin(String username, String userpwd) {
        //实例化dao(持久层)里的接口  用接口new 接口实现类
        UserloginDao userloginDao = new UserLoginDaoImpl();
        Users users = userloginDao.selectUserByUserNameAndUserPwd(username,userpwd);
        //判断user是否查到
        if(users==null){
            //自定义异常
            throw new UserNotFoundException("用户名或密码有误！");
        }
        return users;
    }
}
